JavaScript syntax
part 5/43 Β· 161.3 KB total
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
continues until the end of the line. They are only valid at the start of
#! Hashbang comment
// One-line comment
/* Multi-line
comment */
Variables
(each value has a type) can be stored in any variable. Starting with
ES6, the 6th version of the language, variables could be declared with
var for function scoped variables, and let or const which are for
block level variables. Before ES6, variables could only be declared with
a var statement. Values assigned to variables declared with const cannot
be changed, but their properties can. var should no longer be used since
while subsequent characters can also be digits (0-9). JavaScript is case
sensitive, so the uppercase characters "A" through "Z" are different
from the lowercase characters "a" through "z".
Unicode escape sequences) can be used in identifiers.cite-ref-6[6] In certain
JavaScript implementations, the at sign (@) can be used in an
identifier, but this is contrary to the specifications and not supported
in newer implementations.
Scoping and hoisting
declarations are processed before any code is executed, a variable can
be assigned to and used prior to being declared in the code.cite-ref-7[7] This is
referred to as hoisting, and it is equivalent to variables being
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ